<template>
	<view class="m-position">
		
		<view :class="listType==0||item.type==0?'item dev-box label1':item.type==1?'item dev-box label2':'item dev-box label3'" v-for="(item, index) in positions" :key="index" @click="onClick(item)">
			<view class="mark" v-if="listType==1">{{ item.type==0?'进行中':item.type==1?'已取消':'已结束' }}</view>
			<view class="mark" v-else>{{ item.model==2?'自营':'连锁' }}</view>
			
			
			<view class="title space-between">
				<view class="left">
					<text class="title-name">{{ item.title }}</text>
				</view>
			<!-- 	<text v-if="item.timeMoney>0" class="right">{{ item.timeMoney +'元/小时' }}</text>
				<text v-else="" class="right">{{ item.timeMoney +'元/月' }}</text> -->
				
				<text v-if="item.wayModels=='兼职'" class="right">({{item.wayModels}}){{ item.timeMoney +'元/小时' }}</text>
				<text v-else-if="item.wayModels=='兼职'" class="right">({{item.wayModels}}){{ item.timeMoney +'元/小时' }}</text>
				
				<text v-else="" class="right">({{item.wayModels}}){{ item.timeMoney +'元/月' }}</text>
				
			</view>
			<view class="dateTime">
				<uni-icons type="calendar" style="margin-right:15upx;"></uni-icons>
				{{ formatCreateTime(item.startTime) }}-{{formatCreateTime(item.endTime)}}
			</view>
			<view class="address">
				<uni-icons type="location" style="margin-right:15upx;"></uni-icons>
				{{ item.province }}-{{ item.city}}-{{ item.distinguish}}
				<text v-if="!isAuth" class="distance">距您{{item.distance||10}}km</text>
				<text v-else class="distance">位置未授权</text>
			</view>
			<view class="label" v-if="item.labelList">
				<text  class="title-parttime" v-for="(labelItem, labelIndex) in item.labelList.split(',')">{{labelItem}}</text>
			</view>
		</view>
	</view>
</template>

<script>
import mEmptyData from '@/components/m-empty-data/m-empty-data.vue';
import { formatDate } from '@/common/date';
export default {
	name: 'yzb-position',
	props: {
		positions: Array,
		listType:Number,
		isAuth:Boolean
	},
	components: {
		mEmptyData
	},
	data() {
			moneyShow:false;
		return {
			no_order_1: this.$mAssetsPath.no_order_1
		};
	},

	methods: {
		onClick(item) {
			this.$emit('click', item);
		},

		formatCreateTime(time) {
			if (time == null || time === '') {
				return null;
			}
			let str = time.replace(/-/g,'/');
			let date = new Date(str);
			return formatDate(date, 'yyyy.MM.dd');
		},
		
		formatDistance(distance){
			if(distance){
				let a=parseFloat(distance);
				if(a>0){
					return distance.toFixed(2)+"km"
				}else{
					return a * 1000 +"m";
				}
			}
			return '0km';
		},
	}
};
</script>

<style lang="scss">
.m-position {
	
	.mark{
		color:white;
		font-size: 35upx;
		line-height: 80upx;
		width:120upx;
		text-align: center;
	}
	.label1{
		background-image: url(https://cmtq-1317574530.cos.ap-guangzhou.myqcloud.com/img2023/img/label1.png);
	}
	.label2{
		background-image: url(https://cmtq-1317574530.cos.ap-guangzhou.myqcloud.com/img2023/img/label2.png);
	}
	.label3{
		background-image: url(https://cmtq-1317574530.cos.ap-guangzhou.myqcloud.com/img2023/img/label3.png);
	}
	.item {
		
		background-size: 200upx 90upx;
		background-repeat: no-repeat;
		background-color: $bgcolor_white;
		padding: 0upx 30upx 30upx 30upx;
		// margin-bottom: 20upx;
	}
}
.space-between {
	display: flex;
	justify-content: space-between;
	flex-direction: row;
}
.distance{
	float:right;
	color:#666;
}
.label{
	height:40upx;
	width:100%;
	margin-top:8upx;
	.title-parttime{
		color: #66666E;
		border: 1upx solid #36B957;
		background-color: #F5FFE6;
		font-size: $uni-font-size-sm;
		margin-right: 15upx;
		padding: 4upx 15upx;
		border-radius: 6upx;
		line-height: 40upx;
		float: left;
	}
}
.title {
	margin-top:10upx;
	.title-name{
		font-weight: bold;
		font-size: $uni-font-size-lg;
	}
	.right {
		color: #CB2E2E;
		font-weight: bold;
		font-size: 32upx;
	}
}
</style>
